package com.morphiastic;

import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.common.xcontent.XContentBuilder;

public interface IndexationEventListener {

	/**
	 * Event triggered after the document has been persisted and Before the indexation
	 * 
	 * @param clazz
	 * @param entity
	 */
	public void preIndex(Class<?> clazz, Object entity);
	
	/**
	 * Triggered after a successful indexation to ES
	 * @param clazz
	 * @param entity
	 * @param x
	 */
	public void postIndex(Class<?> clazz, Object entity, XContentBuilder x);
	
	/**
	 * triggered when indexation has failed (ES client spit a IOException for some reason)  
	 * @param clazz
	 * @param entity
	 * @param e the exception that triggered the indexation failure
	 */
	public void onIndexationError(Class<?> clazz, Object entity, Exception e);
	
	
	
	/**
	 * 
	 * @param clazz
	 * @param entity
	 */
	public void preDelete(Class<?> clazz, Object entity);
	
	/**
	 * 
	 * @param clazz
	 * @param entity
	 * @param x
	 */
	public void postDelete(Class<?> clazz, Object entity, DeleteResponse response);
	
	/**
	 * 
	 * @param clazz
	 * @param entity
	 * @param e
	 */
	public void onDeleteError(Class<?> clazz, Object entity, DeleteResponse response);
	
	
	
}
